Skip to content

github-ci mirror: GitHub-side history in the projector (#14170 Q7) - #14299

Merged
dezren39 merged 1 commit into
mainfrom
felix/14170-q7-github-history
Nov 24, 2026
Merged

dezren39 merged 1 commit into
mainfrom
felix/14170-q7-github-history

Conversation

@dezren39

@dezren39 dezren39 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Implements Q7 of the queue-schema design (#14170; design of record doc/2026-11-24T07-23-14Z_design_queue-metadata-history/, §8 + §11): GitHub-side history in the mirror projector (pkgs/github-ci/worker). Q7 depends on nothing in the Q-chain and lands independently of Q1.

What

  • github_issue_history (mirror.sql + MIRROR_DDL, ensured idempotently like every mirror table): one append-only row per observed change — body_edited (hashes only, never bodies), comment_added / comment_removed / comment_count_changed (counts only; the direction kinds only when the delivery itself is an issue_comment action; an agent-note pointer change rides the same row's detail), parent_changed. Diffs are computed from a pre-upsert read under the upserts' own acceptance rules — the tombstone guard and the snapshot/count version guards, spelled in TS beside their SQL twins (the deletionBlocks pattern) — so history never records a change that did not land, and first sights write nothing. Capture is fail-open (design §10.3): history rows are written in their own batch after the mirror batch lands, inside a catch.
  • parent_number projection on github_mirror_issues (additive column, ensureMirrorColumns migration like comments_gh_updated_at): parsed from parent_issue_url in snapshot objects — a parent_known CASE in the upsert keeps the stored value when an object does not state a parent, and a cross-repo parent's repo rides the parent_changed detail — and from sub_issues webhook deliveries (new route in index.ts; unseen children are seeded minimal, as the comment path seeds).
  • Backfill sweep: parent joins the diff key (so the projection populates on the first post-Q7 sweep), and the sweep writes its own diff rows (actor backfill) for the body/count/parent changes it lands, including forced count repairs — flushed fail-open and counted in the run summary (history_rows / history_failed).

Reserved vocabulary, deliberately not written by this slice (per §11 scope): linked / unlinked / state_changed. Emoji reactions remain the design's considered rejection (§8.3). No new dependencies.

Oracle (§11 Q7) — as named tests

Editing a watched issue's body, commenting, and re-parenting a sub-issue each produce exactly one correct row; a killed history write still lands the mirror upsert. All four are tests in test/mirror.test.ts ("mirror history (#14170 Q7)"), plus redelivery, stale-snapshot, first-sight, and silent-parent cases.

Evidence

Remote run (fleet queue dispatch; the executor image has no node/npm, so Node came from nix shell nixpkgs#nodejs_22): run 45372159946 — npm ci (140 packages), tsc --noEmit clean, vitest: 7 files, 91 tests, all passed — mirror.test.ts 34 (15 new Q7 tests), worker.test.ts 20 (incl. the new sub_issues route test), backfill.test.ts 10 (incl. the new parent-bind test).

Side finding, filed + enqueued separately: plain npm ci currently fails on a pre-existing peer conflict (wrangler 4.167 wants @cloudflare/workers-types ^5; the package pins ^4) — #14298, queue task 23064. The verification run used --legacy-peer-deps for that reason only.

Ops note

The sub_issues route receives deliveries only if the webhook subscription includes the sub_issues event — worth confirming in the webhook/App settings at deploy time. The snapshot + sweep parent projection works regardless.

Part of #14170. Queue task 21705.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

- github_issue_history table (mirror.sql + MIRROR_DDL): body_edited
  (hashes only), comment_added / comment_removed /
  comment_count_changed (counts only), parent_changed — diffed
  from a pre-upsert read under the upserts' own acceptance rules
  (tombstone + version guards), written fail-open in their own
  batch after the mirror batch lands.
- parent_number projection on github_mirror_issues, from
  parent_issue_url in snapshot objects (parent_known CASE keeps
  the stored value when an object does not state a parent) and
  from sub_issues webhook deliveries (new route in index.ts).
- Backfill sweep: parent joins the diff key; the sweep writes its
  own diff rows (actor=backfill), including forced count repairs,
  flushed fail-open.
- Oracle tests: a body edit, a comment, and a re-parenting each
  produce exactly one correct row; a killed history write still
  lands the mirror upsert.

Part of #14170 (Q7 of the queue-schema design); queue task 21705.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 22a30fc5-2f05-4b1a-8ea3-2426be284fbc
Commits

Reviewing files that changed from the base of the PR and between 04349a4 and 953cd2e.

Files selected for processing: 7

  • pkgs/github-ci/worker/mirror.sql
  • pkgs/github-ci/worker/scripts/backfill.ts
  • pkgs/github-ci/worker/src/index.ts
  • pkgs/github-ci/worker/src/mirror.ts
  • pkgs/github-ci/worker/test/backfill.test.ts
  • pkgs/github-ci/worker/test/mirror.test.ts
  • pkgs/github-ci/worker/test/worker.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 merged commit 1eac7fd into main Nov 24, 2026
2 checks passed
@dezren39
dezren39 deleted the felix/14170-q7-github-history branch November 24, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant